/*
 * Type.java
 *
 * Copyright (c) 2008 Teamnet. All Rights Reserved.
 *
 * This source file may not be copied, modified or redistributed,
 * in whole or in part, in any form or for any reason, without the express
 * written consent of Teamnet.
 */
package ro.prjmanager.database.conversion;

import java.math.BigDecimal;
import java.util.Date;

/**
 * This class define 2 method:
 * - first method convert database type to java type
 * - the second method that convert java type to database type
 */
public class Type {
    /**
     * This method converts Datbase Type to Java type
     * @param databaseType - Database type
     * @return - coverted database type to java type
     */
     public static String fromDatabaseToJava(String databaseType){
         Class type=null;
         if("NUMBER".equals(databaseType)){
            type=Long.class;
         }else if("INT".equals(databaseType)){
            type=Integer.class;
         }else if("INTEGER".equals(databaseType)){
            type=Integer.class;
         }else if("DATE".equals(databaseType)){
            type= Date.class;
         }else if("VARCHAR2".equals(databaseType)||"NVARCHAR2".equals(databaseType)){
            type=String.class;
         }else if("LONG".equals(databaseType)){
            type=Long.class;
         }else if("NUMERIC".equals(databaseType)){
            type=Integer.class;
         }else if("FLOAT".equals(databaseType)){
            type=Float.class;
         }else if("REAL".equals(databaseType)){
            type=Float.class;
         }else if("SMALLINT".equals(databaseType)){
            type=byte.class;
         }else if("DECIMAL".equals(databaseType)){
            type= BigDecimal.class;
         }else if("VARCHAR".equals(databaseType)||"NVARCHAR".equals(databaseType)){
            type=String.class;
         }
         return type!=null?type.getName():null;

     }

}
